#pragma once

#include "escape.hpp"
#include "limbo/result.h"
#include "slip_context.hpp"

namespace limbo::slip {

template <typename State> struct SlipPacket {
  using LowerState = typename State::LowerState;
  using Context = SlipContext<State>;

  static Result send(State &state, const Context &, Chunk buff,
                     const Chunk payload) {
    return escape(buff, payload, &state);
  }

  Result recv(Chunk buff, State &state, LowerState *) {
    return unescape(buff, &state);
    ;
  }

  Chunk payload;
};

template <typename State>
inline static uint32_t is_ip_packet(const SlipPacket<State> &) {
  return true;
}

template <typename State>
inline static uint32_t get_prefix(const SlipContext<State> &) {
  return 0;
}

} // namespace limbo::slip
